#include <iostream>
#include <unistd.h>

#include "Comm.hpp"

int main()
{
    char buffer[1024];
    SetNonBlock(0);
    while (true)
    {
        ssize_t s = ::read(0, buffer, sizeof(buffer) - 1);
        if (s > 0)
        {
            buffer[s] = 0;
            std::cout << "Echo# " << buffer << std::endl;
        }
        else
        {
            //
            if (errno == EWOULDBLOCK || errno == EAGAIN)
            {
                std::cout << "底层未就绪" << std::endl;
            }
            else
            {
                std::cout << "读取失败" << std::endl;
            }
            sleep(1);
        }
    }
    return 0;
}